<div id="breadcrumb">
    <a onclick="javascript:history.go(-1);" class="go-to-home tip-bottom font font18" style="cursor: pointer;">
        <i class="icon-arrow-left"></i> 返回 &nbsp;
    </a> 
    <a onclick="javascript:history.go(-1);" class="font font18" style="cursor: pointer;"> &nbsp;&nbsp;<span>新用户推广 &gt</span></a>
    <a href="/anchor/anchorinfo?uid={{info['uid']}}" class="current font font18"> <span>详情</span></a>
    
</div>

<!--sidebar-menu-->
<div id="sidebar" class="clearfix">
    <div class="user-info">
        <img alt="" src="{{userInfo['avatar']}}">

        <p>
            <span class="font font20 cr-dpe">{{userInfo['nickName']}}</span>
        </p>
        <p>
            <span class="font font20 cr-dpe">{{userInfo['uid']}}</span>
            <input id="an_uid" type="hidden" value="{{userInfo['uid']}}" />
        </p>
        <div>
            <div style="display: inline-block;margin-top: 8px;vertical-align: top;">备注：</div>
            <div style="margin-top: 7px;line-height: 15px;display: inline-block;max-width: 100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" title="{{recInfo['remark']}}">{{recInfo['remark']}}</div>
            <i class="p-icon-edit editNickName" style="vertical-align: top;" onclick="myDilog2()"></i>
        </div>
    </div>
    <div class="progtrckr-box" style="top: 230px;">
        <div class="progtrckrline" style="height: 130px;"></div>
        <ul class="progtrckr">
            <li class="active"><i class="custom-icon custom-icon-point"></i><a href="/pull/details?uid={{userInfo['uid']}}&id={{userInfo['id']}}">推广的用户</a></li>
            <li><i class="custom-icon custom-icon-point"></i><a href="/pull/payoff?uid={{userInfo['uid']}}&id={{userInfo['id']}}">抽成记录</a></li>
            <li><i class="custom-icon custom-icon-point"></i><a href="/pull/analysis?uid={{userInfo['uid']}}&id={{userInfo['id']}}">分析</a></li>
            <!-- <li><i class="custom-icon custom-icon-point"></i><a  href="/pull/anchorchat?uid={{userInfo['uid']}}">聊天记录</a></li> -->

        </ul>
    </div>
</div>
<!--end sidebar-menu-->

<div id="content">

<div class="container-fluid">
    <div class="row-fluid" style="margin-top: 60px;">
        <!--<div class="thum-box pull-left" style="width: 270px;display: inline-block;">-->
            <!--<div class="thum-top clearfix" style="width: 270px;">-->
                <!--<div class="title">-->
                    <!--<p style="margin-top: 15px"><span>专属链接</span></p>-->
                <!--</div>-->
            <!--</div>-->

            <!--<div class="thum-content " style="width: 270px;">-->
                <!--<p class="font font20 cr-e5">-->
                    <!--<span style="width: 270px;display: inline-block;word-break: break-all;">{{recInfo['url']}}</span>-->
                <!--</p>-->
            <!--</div>-->

        <!--</div>-->


        <div class="thum-box pull-left" style="width: 270px;display: inline-block;">
            <div style="margin: 0 auto; width: 280px;">
                <div class="thum-top ggr clearfix">
                    <div class="title ggr">
                        <p style="margin-top: 15px"><span>抽成比例</span></p>
                    </div>
                </div>

                <div class="thum-content ">
                    <p class="font font20 cr-e5 clearfix">
                        <span class="font font36 cr-ly pull-left" style="margin-left:15px; ">{{recInfo['proportion']}}%</span>
                        <span class="pull-right" style="margin-right: 10px;"><button class="btn" onclick="myDilog1()" >修改</button></span>
                    </p>
                </div>
            </div>
        </div>

        <div class="thum-box pull-left" style="margin-left: 4%;width: 270px;display: inline-block;">
            <div class="pull-right">
                <div class="thum-top bl clearfix">
                    <div class="title bl">
                        <p  style="margin-top: 15px"><span>抽成期限</span></p>
                    </div>
                </div>

                <div class="thum-content " >
                    <p class="font font20 cr-e5 clearfix">
                        <span class="font font36 cr-ly pull-left" style="margin-left:15px; ">{{recInfo['validity']}}天</span>
                        <span class="pull-right" style="margin-right: 10px;"><button class="btn" onclick="myDilog()" >修改</button></span>
                        <span class="font font18 cr-ly pull-left" style="margin-left:15px; ">到期时间：{{recInfo['dueTime']}}</span>
                    </p>
                </div>
            </div>
        </div>

        <span class="pull-left" style="width: 270px;display: inline-block;margin-left: 4%;margin-top: -50px;">
            <!--<a rel="example_group" href="{{recInfo['img']}}" title=""><img alt="" src="{{recInfo['img']}}"></a>-->
            <img src="{{recInfo['img']}}">
        </span>

    </div>
    <div class="content-box font18" style="background-color: #fff;margin-top:10px;padding-left: 40px;padding: 20px 40px;">
        <button type="button" onclick="delrecommendDialog()"  class="btn btn-purple pull-right" style="margin-top: 20px;">删除</button>
         <div><span>旧版链接：</span><span>{{recInfo['url']}}</span></div>
         <div style="margin-top: 20px;"><span>长链接：</span><span>{{recInfo['longUrl']}}</span></div>
         <div style="margin-top: 20px;"><span>短链接：</span><span>{{recInfo['tinyUrl']}}</span></div>
    </div>
    <div class="content-box" style="background: #FFF; text-align: left; margin-top:20px;  padding-bottom: 40px;">
        <ul class="tab-nav clearfix">
            <li class="tabs-nav active"><a href="#">推广的用户</a></li>
        </ul>
    <div class="hr-d7"></div>
    <div id="box1" class="tab-box">


    <div class="row-fluid" style="margin-top: 30px;">
        <div class="container-fluid">
            <div style="margin-top: -30px">
                <table id="tableList" class="table with-check table-purple">
                    <thead>
                    <tr>
                        <th>uid</th>
                        <th>昵称</th>
                        <th>注册时间</th>
                        <th>累计充值金额</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
                {% include "common/pagination.html" %}

            </div>
        </div>
    </div>

</div>

</div>
</div>

</div>

<div id="delrecommendDialog" style="display:none">
    <div style="height: 115px;line-height: 115px;text-align: center;font-size: 16px;">确定删除这个推广链接？</div>
</div>

<div id="delrecommendDialog1" style="display:none">
    <div style="height: 115px;line-height: 115px;text-align: center;font-size: 16px;">是否删除该推广用户？</div>
</div>

<div id="myDilog2" style="display:none;font-size: 16px;color: #9ea3a0;">
    <form id="addnumDialogForm2">
        <div style="margin-top: 20px;">请输入输入新的备注：</div>
        <input id="grantNum2" style="margin-top: 20px;width: 300px;height: 30px;" type="text">
    </form>
</div>

<div id="myDilog1" style="display:none;font-size: 16px;color: #9ea3a0;">
    <form id="addnumDialogForm1">
        <div style="margin-top: 20px;">请输入输入新的抽成比例：</div>
        <input id="grantNum1" onkeydown="onlyNum()" style="margin-top: 20px;width: 300px;height: 30px;" type="text">
        %
    </form>
</div>

<div id="myDilog" style="display:none;font-size: 16px;color: #9ea3a0;">
    <form id="addnumDialogForm">
        <div style="margin-top: 20px;">请输入输入新的期限：</div>
        <input id="grantNum" onkeydown="onlyNum()" style="margin-top: 20px;width: 300px;height: 30px;" type="text">
        天
    </form>
</div>

<link rel="stylesheet" href="{{static_url('web/css/icon/style-icon.css')}}">
<!--<script type="text/javascript" src="{{static_url('web/js/jquery.fancybox-1.3.1.js')}}"></script>-->
<!--<link rel="stylesheet" href="{{static_url('web/css/jquery.fancybox-1.3.1.css')}}" type="text/css" />-->
<script type="text/javascript">

    $(function() {
        $('body').addClass('anchorinfo');
        getDataList();
        $('#grantNum1').on('blur',checkproportion);
//
//        $("a[rel=example_group]").fancybox({
//            'transitionIn'		: 'none',
//            'transitionOut'		: 'none',
//            'titlePosition' 	: 'over',
//            'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
//                return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
//            }
//        });
    });

    function checkproportion(){
        var a=$('#grantNum1').val();
        if(a>100||a<1){
            $('#proportion').attr('data',1);
            alert('限1-100的数字');
        }
        else{
            $('#proportion').attr('data',0);
        }
    }

    function getDataList(index){
        var data={};
        data.uid=$('#an_uid').val();
        data.page=index||1;
        data.pageSize=global.pageSize;
        $.ajax({
            type:"POST",
            data:data,
            url:'/ajax/getRecDetailList',
            dataType:'json',
            success:function(res){
                var data=res.data;
                var tableList=document.getElementById("tableList");
                var tbody= tableList.getElementsByTagName('tbody')[0];
                dataTable.clearData(tbody);


                var count=document.getElementById('count');
                count.innerHTML=data.count;

                for(var i=0;i<data.data.length;i++){
                    addRow(tbody,data.data[i]);
                }
                if(!index||index==0){
                    utilsPagination("#pagination",data.count,global.pageSize,function(page_index,jq){
                        page_index+=1;
                        getDataList(page_index);
                    });
                }
            }

        });
    }

    function addRow(table,data){

        var row=table.insertRow();
        var cell=row.insertCell(0);
        var cell1=row.insertCell(1);
        var cell2=row.insertCell(2);
        var cell3=row.insertCell(3);
        var cell4=row.insertCell(4);

        var div=document.createElement("div"),
                img=document.createElement("img"),
                span=document.createElement("span");

        div.className="anchor-info";
        img.src=global.contract+data.avatar;
        span.innerHTML=data.beRecUid;

        div.appendChild(img);
        div.appendChild(span);

        cell.appendChild(div);

        cell1.innerHTML=data.nickName;
        cell2.innerHTML=ns_getTime(data.createTime);
        cell3.innerHTML=data.totalFee;
        cell4.innerHTML='<a class="a-edit font font18 cr-pe cursor-pointer" onclick="delrecommendDialog1('+data.id+')">删除</a>';

        return row;
    }


    //  修改期限1-比例2-期限3-备注
    function myDilog(id){

    $('#myDilog').dialog({
        autoOpen:true,
        width:400,
        height:250,
        title:'修改抽成期限',
        resizable:false,
        modal:true,
        open:function(){

        },
        buttons: {
            "确定": function () {
                var data={};
                data.type=2;
                data.uid=$('#an_uid').val();
                data.editInfo=$('#grantNum').val();
                $.ajax({
                    type:"POST",
                    data:data,
                    url:'/ajax/editRecInfo',
                    dataType:'json',
                    success:function(res){
                        location.reload();
                    }

                });


            }//,
            /*"取消": function () {


            }*/
        }
    });
}

    //  修改比例
    function myDilog1(id){

        $('#myDilog1').dialog({
            autoOpen:true,
            width:400,
            height:250,
            title:'修改抽成比例',
            resizable:false,
            modal:true,
            open:function(){

            },
            buttons: {
                "确定": function () {
                    var data={};
                    data.type=1;
                    data.uid=$('#an_uid').val();
                    data.editInfo=$('#grantNum1').val();
                    $.ajax({
                        type:"POST",
                        data:data,
                        url:'/ajax/editRecInfo',
                        dataType:'json',
                        success:function(res){
                            location.reload();
                        }

                    });


                }//,
                /*"取消": function () {


                 }*/
            }
        });
    }

    //  修改备注
    function myDilog2(id){

        $('#myDilog2').dialog({
            autoOpen:true,
            width:400,
            height:250,
            title:'修改备注',
            resizable:false,
            modal:true,
            open:function(){

            },
            buttons: {
                "确定": function () {
                    var data={};
                    data.type=3;
                    data.uid=$('#an_uid').val();
                    data.editInfo=$('#grantNum2').val();
                    $.ajax({
                        type:"POST",
                        data:data,
                        url:'/ajax/editRecInfo',
                        dataType:'json',
                        success:function(res){
                            location.reload();
                        }

                    });


                }//,
                /*"取消": function () {


                 }*/
            }
        });
    }


    //  新用户推荐删除
    function delrecommendDialog(id){

        $('#delrecommendDialog').dialog({
            autoOpen:true,
            width:440,
            height:250,
            title:'删除',
            resizable:false,
            modal:true,
            open:function(){
            },
            buttons: {
                "确定": function () {
                    var data={};
                    data.id=getUrlParam('id');
                    $.ajax({
                        type:"POST",
                        data:data,
                        url:'/ajax/delRec',
                        dataType:'json',
                        success:function(res){
                            if(res.code!=0){
                                alert(res.info);
                            }
                            location.href='/pull/reclist';
                        }

                    });

                }
            }
        });
    }


    //  单个推广用户删除
    function delrecommendDialog1(id){

        $('#delrecommendDialog1').dialog({
            autoOpen:true,
            width:440,
            height:250,
            title:'删除',
            resizable:false,
            modal:true,
            open:function(){
            },
            buttons: {
                "确定": function () {
                    var data={};
                    data.id=id;
                    $.ajax({
                        type:"POST",
                        data:data,
                        url:'/ajax/delRecLog',
                        dataType:'json',
                        success:function(res){
                            if(res.code!=0){
                                alert(res.info);
                            }
                            location.reload();
                        }

                    });

                }
            }
        });
    }
</script>